package{
    import flash.display.Sprite;
    import flash.text.TextField;
    import net.mk25.audio.Mp3FileHandler;    
    import flash.net.*;
    import flash.media.*;
    import flash.events.KeyboardEvent;
    import flash.display.Stage;
    import flash.ui.Keyboard;

    public class Mp3FileHandlerTest extends Sprite {

        private var myMp3FileHandler:Mp3FileHandler;        



        //private static var stage:Stage;
        public function Mp3FileHandlerTest() {
            var mp3UrlRequest:URLRequest = new URLRequest("songs/song.mp3");

            myMp3FileHandler = new Mp3FileHandler(mp3UrlRequest, null);
            myMp3FileHandler.playAt(20000); 

            this.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler); 

            

        }
        function keyDownHandler(event : KeyboardEvent) : void {     
            if (event.keyCode == Keyboard.DOWN){
                myMp3FileHandler.stop();
            }
            if (event.keyCode == Keyboard.UP){
                myMp3FileHandler.replay();
            }
            if (event.keyCode == Keyboard.ENTER){
                if(myMp3FileHandler.getStatus() == Mp3FileHandler.PAUSED){
                    myMp3FileHandler.play();
                }else  myMp3FileHandler.pause();

            }
        }
    }
}
